<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>中因医院</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <!-- 地址栏显示 -->
    <link rel="Shortcut Icon" href="/images/hospital.png" type="image/x-icon"/>
    <!-- 收藏栏也显示 -->
    <link rel="Bookmark" href="/images/hospital.png"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">
            <img class="lowin-brand" src="/sb-admin-2/img/hospitalLogo.png" style="width: 45px; height: 39px;"
                 alt="logo">中因医院
        </div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;" id="adminname">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="/view/userInfo.html">个人中心</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="/logout">退出登录</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree layui-nav-side" lay-filter="treenav" id="menu">
                <span class="layui-nav-bar"></span>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        挂号收费 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M1">
                        <dd class="layui-nav-item">
                            <a href="javascript:;" class="site-url" data-title="挂号收费" data-id="9"
                               data-url="/view/register/register.html">挂号收费</a>
                        </dd>
                        <dd class="layui-nav-item">
                            <a href="javascript:;" class="site-url" data-title="挂号记录" data-id="12"
                               data-url="/view/register/registerRecord.html">挂号记录</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        门诊管理 <i class="layui-icon layui-icon-down layui-nav-more"></i>
                    </a>
                    <dl class="layui-nav-child" id="M2">
                        <dd class="layui-nav-item">
                            <a href="javascript:;" class="site-url" data-title="门诊就诊" data-id="14"
                               data-url="/view/outpatient/outpatient.html">门诊就诊
                            </a>
                        </dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="门诊记录"
                                                      data-id="15" data-url="/view/outpatient/medicalRecord.html">门诊记录
                        </a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        划价收费 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M3">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="门诊收费"
                                                      data-id="16" data-url="/view/toll/outpatientToll.html">门诊收费</a>
                        </dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="体检收费"
                                                      data-id="17" data-url="/view/toll/examinationToll.html">体检收费</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        药房取药 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M4">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="药房取药"
                                                      data-id="18" data-url="/view/takingdrug/takingdrug.html">药房取药</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        体检管理 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M5">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="普通体检"
                                                      data-id="19"
                                                      data-url="/view/medicalExamination/medicalExamination.html">普通体检</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        用户中心 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M7">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="个人中心"
                                                      data-id="20" data-url="/view/userInfo.html">个人中心</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        药库管理 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M6">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="药物信息管理"
                                                      data-id="10" data-url="/view/admin/drug.html">药物信息管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="入库管理"
                                                      data-id="13" data-url="/view/admin/stock.html">入库管理</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        信息管理 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M8">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="字典类型管理"
                                                      data-id="21" data-url="/view/admin/dicttype.html">字典类型管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="字典管理"
                                                      data-id="22" data-url="/view/admin/dite.html">字典管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="科室管理"
                                                      data-id="23" data-url="/view/admin/department.html">科室管理</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        系统管理 <i class="layui-icon layui-icon-down layui-nav-more"></i></a>
                    <dl class="layui-nav-child" id="M9">
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="患者管理"
                                                      data-id="11" data-url="/view/admin/patient.html">患者管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="公告管理"
                                                      data-id="24" data-url="/view/admin/announcement.html">公告管理</a>
                        </dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="管理员管理"
                                                      data-id="25" data-url="/view/admin/user.html">管理员管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="角色管理"
                                                      data-id="26" data-url="/view/admin/role.html">角色管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="菜单管理"
                                                      data-id="27" data-url="/view/admin/menu.html">菜单管理</a></dd>
                        <dd class="layui-nav-item"><a href="javascript:;" class="site-url" data-title="登录记录"
                                                      data-id="28" data-url="/view/admin/loginInfo.html">登录记录</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-tab layui-tab-brief" lay-filter="contentnav" lay-allowClose="true"
         style="margin-left:200px;margin-top:55px;">
        <ul class="layui-tab-title">
            <li class="layui-this">首页</li>
        </ul>
        <ul class="layui-bg-green rightmenu" style="display: none;position: absolute;">
            <li data-type="closethis">关闭当前</li>
            <li data-type="closeall">关闭所有</li>
        </ul>
        <div class="layui-tab-content" style="padding:0;">
            <div class="layui-tab-item layui-show">
                <iframe data-frameid="2" scrolling="auto" frameborder="0" src="/view/main2.html"
                        style="width: 100%; height: 680px;"></iframe>
            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        底部固定区域
    </div>
</div>

<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'element'], function () {
        var element = layui.element;
        var $ = layui.jquery;

        $.get('/getUser', function (res) {
            $("#adminname").append(res.data.username);
        });

        //获取菜单信息，并进行页面渲染
        // $.ajax({
        //     url: "/getUidMenu",
        //     type: "get",
        //     dataType: "json",
        //     success: function (res) {
        //         // console.log(res);
        //         if (res.status == 1) {
        //             $.each(res.data, function (i, obj) {
        //                 if (obj.menuType == "M") {
        //                     $("#menu").append('<li class="layui-nav-item">\n' +
        //                         '\t\t\t<a href="javascript:;">\n' +
        //                         obj.menuName +
        //                         '\t\t\t</a>\n' +
        //                         '\t\t\t<dl class="layui-nav-child" id = "M' + obj.menuId + '">\n' +
        //                         '\t\t\t</dl>\n' +
        //                         '\t\t</li>'
        //                     );
        //                 }else if (obj.menuType == "C"){
        //                     $("#M"+obj.parentId).append('<dd class="layui-nav-item">'+
        //                         '<a href="javascript:;" class="site-url" data-title="'+obj.menuName+ '"' +
        //                         ' data-id="'+i+ '"' +/*obj.orderNum*/' data-url="'+obj.url+'">'+
        //                         obj.menuName+'</a></dd>');
        //                 }
        //             });
        //             //从新加载
        //             element.render();
        //         }
        //     }
        // });

        var active = {
            tabAdd: function (url, id, name) {
                element.tabAdd('contentnav', {
                    title: name,
                    content: '<iframe data-frameid="' + id +
                        '" scrolling="auto" frameborder="0" src="' + url +
                        '" style="width:99%;"></iframe>',
                    id: id
                });
                rightMenu();
                iframeWH();
            },
            tabChange: function (id) {
                element.tabChange('contentnav', id);
            },
            tabDelete: function (id) {
                element.tabDelete('contentnav', id);
            },
            tabDeleteAll: function (ids) {
                $.each(ids, function (index, item) {
                    element.tabDelete('contentnav', item);
                });
            }
        };
        //$(".site-url").on('click', function () {
        $(document).on('click', '.site-url', function () {
            var nav = $(this);
            var length = $("ul.layui-tab-title li").length;
            if (length <= 0) {
                active.tabAdd(nav.attr("data-url"), nav.attr("data-id"), nav.attr("data-title"));
            } else {
                var isData = false;
                $.each($("ul.layui-tab-title li"), function () {
                    if ($(this).attr("lay-id") == nav.attr("data-id")) {
                        isData = true;
                    }
                });
                if (isData == false) {
                    active.tabAdd(nav.attr("data-url"), nav.attr("data-id"), nav.attr("data-title"));
                }
                active.tabChange(nav.attr("data-id"));
            }
        });

        function rightMenu() {
            //右击弹出
            $(".layui-tab-title li").on('contextmenu', function (e) {
                var menu = $(".rightmenu");
                menu.find("li").attr('data-id', $(this).attr("lay-id"));
                l = e.clientX;
                t = e.clientY;
                menu.css({
                    left: l,
                    top: t
                }).show();
                return false;
            });
            //左键点击隐藏
            $("body,.layui-tab-title li").click(function () {
                $(".rightmenu").hide();
            });
        }

        $(document).on('click', '.rightmenu li', function () {
            // $(".rightmenu li").click(function () {
            if ($(this).attr("data-type") == "closethis") {
                active.tabDelete($(this).attr("data-id"));
            } else if ($(this).attr("data-type") == "closeall") {
                var tabtitle = $(".layui-tab-title li");
                var ids = new Array();
                tabtitle.each(function (i) {
                    ids.push($(this).attr("lay-id"));
                });
                //如果关闭所有 ，即将所有的lay-id放进数组，执行tabDeleteAll
                active.tabDeleteAll(ids);
            }
            $('.rightmenu').hide(); //最后再隐藏右键菜单
        });

        function iframeWH() {
            var H = $(window).height() - 120;
            $("iframe").css("height", H + "px");
        }

        $(window).resize(function () {
            iframeWH();
        });


    });
</script>

</body>
</html>